#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
int main()
{
	int n = 0, m = 0;
	scanf("%d %d", &n, &m);
	int arr[2000] = { 0 };
	int i = 0;
	for (i = 0; i < n; i++)
		scanf("%d", &arr[i]);
	for (i = n; i < n + m; i++)
		scanf("%d", &arr[i]);
	int j = 0;
	for (i = 0; i < n + m - 1; i++)
	{
		for (j = 0; j < n + m - i - 1; j++)
		{
			int temp;
			if (arr[j] > arr[j + 1])
			{
				temp = arr[j];
				arr[j] = arr[j + 1];
				arr[j + 1] = temp;
			}
		}
	}
	for (i = 0; i < n + m; i++)
		printf("%d ", arr[i]);
	return 0;
}